package com.bstek.bdf2.core.business;

import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.Collections;

public abstract class AbstractUser
  implements IUser
{
  private static final long serialVersionUID = 5125145011670416263L;

  public final Collection<? extends GrantedAuthority> getAuthorities()
  {
    return getRoles() == null ? Collections.emptyList() : getRoles();
  }

  public boolean isAccountNonExpired() {
    return true;
  }
  public boolean isAccountNonLocked() {
    return true;
  }
  public boolean isCredentialsNonExpired() {
    return true;
  }

  public int hashCode()
  {
    if (getUsername() != null) {
      return getUsername().hashCode();
    }
    return -1;
  }

  public boolean equals(Object obj)
  {
    if (((obj instanceof AbstractUser)) && (obj.hashCode() == hashCode())) {
      return true;
    }
    return false;
  }
}